feat: support Voyage embeddings via MongoDB Atlas (mongodb/ prefix)#206
Open
antronic wants to merge 1 commit into
Open
feat: support Voyage embeddings via MongoDB Atlas (mongodb/ prefix)#206antronic wants to merge 1 commit into
antronic wants to merge 1 commit into
Conversation
Route 'mongodb/<voyage-model>' model names through LiteLLM's voyage provider with api_base set to https://ai.mongodb.com/v1. MongoDB Atlas serves Voyage models over the native Voyage API using a VOYAGE_API_KEY bearer token, so the same input_type curated defaults apply.
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds support for accessing Voyage AI embedding models through MongoDB Atlas.
When the configured embedding model name starts with the
mongodb/prefix (e.g.mongodb/voyage-4-large), the embedder now:mongodb/voyage-4-large→voyage/voyage-4-large).api_basetohttps://ai.mongodb.com/v1, which is the Atlas-hosted Voyage embedding endpoint.MongoDB Atlas serves Voyage models over the native Voyage API (same request/response
shape, authenticated with a
VOYAGE_API_KEYbearer token), so routing through thevoyage/provider with an overriddenapi_baseis sufficient — no new provider orresponse transformation is required. This was verified against LiteLLM's
VoyageEmbeddingConfig.get_complete_url, which honors a caller-suppliedapi_base.Changes
src/cocoindex_code/litellm_embedder.py: add_resolve_mongodb_model()helper; mapmongodb/*→voyage/*inPacedLiteLLMEmbedder.__init__and inject the Atlasapi_baseinrun_embedding_request. Because the resolved model uses thevoyage/prefix, the existing native-provider branch already skips forcing
encoding_format/drop_params.src/cocoindex_code/embedder_defaults.py: extend the curated Voyage defaults regex to(voyage|mongodb)/.+soccc initapplies the sameinput_type(document/query)defaults to Atlas-hosted Voyage models.
EMBEDDINGS.md: document themongodb/configuration option.tests/test_litellm_embedder.py(routing + Atlasapi_base)and
tests/test_embedder_defaults.py(curated defaults match).Example configuration
Motivation and context
MongoDB Atlas now offers the Voyage AI Embedding and Reranking API at
https://ai.mongodb.com/v1. Users with an Atlas model API key could not pointcccatthis endpoint, since LiteLLM has no
mongodbprovider and the model string was passedthrough unchanged. This change lets those users select Atlas-hosted Voyage models with a
simple
mongodb/prefix while reusing the existing Voyage code path and curated defaults.Reference: https://www.mongodb.com/docs/voyageai/api-and-clients/
Breaking change
No. This is purely additive — existing
voyage/,openai/, and other model strings areunaffected.
Related issues
None.
Testing
uv run mypy .— no new issues on changed files.uv run pytest tests/test_litellm_embedder.py tests/test_embedder_defaults.py tests/test_shared.py— pass.prek run --all-files— the only failures were two pre-existing flaky daemon-lifecyclee2e tests (
test_session_db_path_mapping,test_index_and_search_via_client), whichpass when run in isolation and are unrelated to this change.